package io;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamTest {
    public static void main(String[] args) {
        FileOutputStream outputStream = null;
        File file = new File("C:\\Users\\Shinelon\\Desktop\\乱七八糟\\javastudy\\Test.txt");
        try {
            outputStream = new FileOutputStream(file,true);
            String s = "1 + 2 = 3";
            byte[] bytes = s.getBytes();
            outputStream.write(bytes);
            outputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (outputStream != null){
                try {
                    outputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
